clear all
set more off

quiet do load_rreg2
local out2="\outregsQJE\"
local in2 ="\Data_and_Codes\"
cd "\workfiles"

*-------------------------------------------------------------------------------
* aggrgegate data to the annual frequency in the official sources
*-------------------------------------------------------------------------------

*** balance sheet data
use "`in2'CGR_2006q1_2019q1_clean_ONLYCERVED.dta"
gen trimestre = quarter(dofq(time))
keep if trimestre == 1
drop trimestre
gen anno = yofd(dofq(time))
drop time
tsset firm_id anno
save "`in2'temp_ONLYCERVED.dta", replace


*** SSA data
use "`in2'CGR_2006q1_2019q1_clean_ONLYINPSWAGE.dta"
gen trimestre = quarter(dofq(time))
keep if trimestre == 1
drop trimestre
gen anno = yofd(dofq(time))
drop time
tsset firm_id anno
save "`in2'temp_ONLYINPSWAGE.dta", replace

*** SSA data: employment
use "`in2'CGR_2006q1_2019q1_clean_ONLYINPSADD.dta"

gen anno = yofd(dofq(time))
collapse (mean) add_new, by(firm_id anno)
tsset firm_id anno
save "`in2'temp_ONLYINPSADD.dta", replace

*** SSA data: temporary workers
use "`in2'CGR_2006q1_2019q1_clean_ONLYINPSTEMPWORK.dta"
tsset firm_id anno
save "`in2'temp_ONLYINPSTEMPWORK.dta", replace


*-------------------------------------------------------------------------------
* 		aggrgegate SIGE data to the annual frequency 
*-------------------------------------------------------------------------------


use step001_QJE_2, clear
tsset firm_id time

*** define treatment as given inflation TIMES treatment status
gen Treat=treatment_old*infl

*** winsorize actual and expected price changes
winsor dpre, gen(dpre_w) p(0.02)
winsor dprez, gen(dprez_w) p(0.02)

*-------------------------------------------------------------------------------
***				 collapse data to the annual frequency
*-------------------------------------------------------------------------------
foreach var in  dprez_w  sitimp5  occtot  sitgen  promig  liquid {
	gen L_`var'= `var'
}

	
collapse  ///
		(last)  last_it12_all = it12_all ///
				last_Treat = Treat ///
				last_time = time ///
				last_dprez_w = dprez_w ///
				last_sitimp5 = sitimp5 ///
				last_occtot = occtot ///
				last_sitgen = sitgen ///
				last_promig = promig ///
				last_liquid = liquid  /// 
				last_peso = peso /// /* samping weight */
				last_lnL = lnL ///
				last_dpre_w = dpre_w ///
		///
		(first) first_it12_all = it12_all ///
				first_Treat = Treat ///
				first_time = time ///
				first_dprez_w = dprez_w ///
				first_sitimp5 = sitimp5 ///
				first_occtot = occtot ///
				first_sitgen = sitgen ///
				first_promig = promig ///
				first_liquid = liquid  /// 
				first_peso = peso /// /* samping weight */
				first_lnL = lnL ///
				first_dpre_w = dpre_w ///
		///
		(mean)  mean_it12_all = it12_all ///
				mean_Treat = Treat ///
				mean_time = time ///
				mean_dprez_w = dprez_w ///
				mean_sitimp5 = sitimp5 ///
				mean_occtot = occtot ///
				mean_sitgen = sitgen ///
				mean_promig = promig ///
				mean_liquid = liquid  /// 
				mean_peso = peso /// /* samping weight */
				mean_lnL = lnL ///
				mean_dpre_w = dpre_w ///				
		 (last) setton3 setton5 /// /*industry */	
		(count) N_lnL = lnL ///
				N_it12_all = it12_all ///
				N_treatment_old=treatment_old ///
				, by(firm_id anno)


*-------------------------------------------------------------------------------
*					add annual data from official sources
*-------------------------------------------------------------------------------
*Yuriy
*use "C:\Dropbox\CGR\Data_and_Codes\CGR_2006q1_2019q1_clean_ONLYCERVED.dta"
*Tiziano


joinby firm_id anno using "`in2'temp_ONLYCERVED.dta", unmatched(master)
tab anno _merge
drop _merge


joinby firm_id anno using "`in2'temp_ONLYINPSWAGE.dta", unmatched(master)
tab anno _merge
drop _merge


joinby firm_id anno using "`in2'temp_ONLYINPSADD.dta", unmatched(master)
tab anno _merge
drop _merge



joinby firm_id anno using "`in2'temp_ONLYINPSTEMPWORK.dta", unmatched(master)
tab anno _merge
drop _merge


tsset firm_id anno	

keep if last_time>=208

gen lnL_new=log(add_new)*100
winsor lnL_new, gen(lnL_new_w2) p(0.03)

drop if anno==2019 /* incomplete year */

***======================================================
*** 	vector of controls	
***======================================================

local controls0=" last_dprez_w i.last_sitimp5 i.last_occtot i.last_sitgen i.last_promig i.last_liquid "	

***======================================================
*** 	output 	
***======================================================

tempname 1 
postfile `1' ///
		str50 variable_name 	///												
		str12 v_coef_se				///
		str12 v_R2 ///
		str12 v_F1 ///
		str12 v_N ///
		using `out2'Table04.dta, replace
		
		
***======================================================
*** 	responses to treatment	
***======================================================

***	Labor response at the annual frequency
capture drop FC1
gen FC1=f.mean_lnL-l.mean_lnL
capture drop FC1_w2
winsor FC1, gen(FC1_w2) p(0.02)
ivreghdfe FC1_w2 `controls0' ///
	(l.last_it12_all = l.last_Treat) [aw=mean_peso], ///
	dkraay(3) absorb(i.setton5)	

outreg2 using "`out2'response_annual.dta", replace  dec(3)  ///
	addstat( "1st stage F stat", e(widstat))  ctitle("employment: survey")	

	local t1=_b[l.last_it12_all]/_se[l.last_it12_all]
	if abs(`t1')<=1.645 local stars=""
	if abs(`t1')>1.645 local stars="*"
	if abs(`t1')>1.960 local stars="**"
	if abs(`t1')>2.326 local stars="***"
	
	local v_coef=string(_b[l.last_it12_all],"%4.3f")+"`stars'"
	local v_se  ="(" + string(_se[l.last_it12_all],"%4.3f")+")"
	local v_R2  =string(e(r2c),"%5.3f")
	local v_F1  = string(e(widstat),"%5.2f")
	local v_N  = string(e(N),"%8.0gc")
	
	
    post `1' ("Employment (SIGE)") ("`v_coef'") ("`v_R2'") ("`v_F1'") ("`v_N'")
    post `1' (" ") ("`v_se'") (" ") (" ") (" ")	
	


***	Labor (official) response at the annual frequency
capture drop FC1
* gen FC1=f.lnL_new-l.lnL_new
gen FC1=f.lnL_new_w2-l.lnL_new_w2

capture drop FC1_w2
winsor FC1, gen(FC1_w2) p(0.02)
ivreghdfe FC1_w2 `controls0' ///
	(l.last_it12_all = l.last_Treat) [aw=mean_peso], ///
	dkraay(3)  absorb(i.setton5) 	

outreg2 using "`out2'response_annual.dta", append  dec(3)  ///
	addstat( "1st stage F stat", e(widstat))  ctitle("employment: SSA")	
	
	local t1=_b[l.last_it12_all]/_se[l.last_it12_all]
	if abs(`t1')<=1.645 local stars=""
	if abs(`t1')>1.645 local stars="*"
	if abs(`t1')>1.960 local stars="**"
	if abs(`t1')>2.326 local stars="***"
	
	local v_coef=string(_b[l.last_it12_all],"%4.3f")+"`stars'"
	local v_se  ="(" + string(_se[l.last_it12_all],"%4.3f")+")"
	local v_R2  =string(e(r2c),"%5.3f")
	local v_F1  = string(e(widstat),"%5.2f")
	local v_N  = string(e(N),"%8.0gc")
	
	
    post `1' ("Employment (INPS)") ("`v_coef'") ("`v_R2'") ("`v_F1'") ("`v_N'")
    post `1' (" ") ("`v_se'") (" ") (" ") (" ")	
	
	
***	Fixed (tangile) assets at the annual frequency
capture drop lnFA
gen lnFA=log(c002)*100
capture drop lnFA_w2
winsor lnFA, gen(lnFA_w2) p(0.02)

capture drop FC1
gen FC1=f.lnFA_w2-l.lnFA_w2
capture drop FC1_w2
winsor FC1, gen(FC1_w2) p(0.02)
ivreghdfe FC1_w2 `controls0' ///
	(l.last_it12_all = l.last_Treat) [aw=mean_peso], ///
	dkraay(2) absorb(i.setton5)		

outreg2 using "`out2'response_annual.dta", append  dec(3)  ///
	addstat( "1st stage F stat", e(widstat))  ctitle("Fixed assets")	
	
	local t1=_b[l.last_it12_all]/_se[l.last_it12_all]
	if abs(`t1')<=1.645 local stars=""	
	if abs(`t1')>1.645 local stars="*"
	if abs(`t1')>1.960 local stars="**"
	if abs(`t1')>2.326 local stars="***"
	
	local v_coef=string(_b[l.last_it12_all],"%4.3f")+"`stars'"
	local v_se  ="(" + string(_se[l.last_it12_all],"%4.3f")+")"
	local v_R2  =string(e(r2c),"%5.3f")
	local v_F1  = string(e(widstat),"%5.2f")
	local v_N  = string(e(N),"%8.0gc")
	
	
    post `1' ("Fixed assets (CERVED)") ("`v_coef'") ("`v_R2'") ("`v_F1'") ("`v_N'")
    post `1' (" ") ("`v_se'") (" ") (" ") (" ")		
	
	
***	Sales growth at the annual frequency
capture drop lnSales
gen lnSales=log(c051)*100
capture drop lnSales_w2
winsor lnSales, gen(lnSales_w2) p(0.02)
capture drop FC1
gen FC1=f.lnSales_w2-l.lnSales_w2
capture drop FC1_w2
winsor FC1, gen(FC1_w2) p(0.02)
ivreghdfe FC1_w2 `controls0' ///
	(l.last_it12_all = l.last_Treat) [aw=mean_peso], ///
	dkraay(2) absorb(i.setton5)		

outreg2 using "`out2'response_annual.dta", append  dec(3)  ///
	addstat( "1st stage F stat", e(widstat))  ctitle("Sales")	
	
	local t1=_b[l.last_it12_all]/_se[l.last_it12_all]
	if abs(`t1')<=1.645 local stars=""	
	if abs(`t1')>1.645 local stars="*"
	if abs(`t1')>1.960 local stars="**"
	if abs(`t1')>2.326 local stars="***"
	
	local v_coef=string(_b[l.last_it12_all],"%4.3f")+"`stars'"
	local v_se  ="(" + string(_se[l.last_it12_all],"%4.3f")+")"
	local v_R2  =string(e(r2c),"%5.3f")
	local v_F1  = string(e(widstat),"%5.2f")
	local v_N  = string(e(N),"%8.0gc")
	
	
    post `1' ("Sales (CERVED)") ("`v_coef'") ("`v_R2'") ("`v_F1'") ("`v_N'")
    post `1' (" ") ("`v_se'") (" ") (" ") (" ")			
	
	
***	Liquidity (current assets to total assets) at the annual frequency
capture drop LIQUID
gen LIQUID=(c014/c015)*100
capture drop LIQUID_w
winsor LIQUID, gen(LIQUID_w) p(0.02)
capture drop FC1
capture drop FC1
gen FC1=f.LIQUID_w-l.LIQUID_w
capture drop FC1_w2
winsor FC1, gen(FC1_w2) p(0.02)
ivreghdfe FC1_w2 `controls0' ///
	(l.last_it12_all = l.last_Treat) [aw=mean_peso], ///
	dkraay(2) absorb(i.setton5)		
	

outreg2 using "`out2'response_annual.dta", append  dec(3)  ///
	addstat( "1st stage F stat", e(widstat))  ctitle("Liquidity")	
	
	local t1=_b[l.last_it12_all]/_se[l.last_it12_all]
	if abs(`t1')<=1.645 local stars=""
	if abs(`t1')>1.645 local stars="*"
	if abs(`t1')>1.960 local stars="**"
	if abs(`t1')>2.326 local stars="***"
	
	local v_coef=string(_b[l.last_it12_all],"%4.3f")+"`stars'"
	local v_se  ="(" + string(_se[l.last_it12_all],"%4.3f")+")"
	local v_R2  =string(e(r2c),"%5.3f")
	local v_F1  = string(e(widstat),"%5.2f")
	local v_N  = string(e(N),"%8.0gc")
	
	
    post `1' ("Current assets to total assets (CERVED)") ("`v_coef'") ("`v_R2'") ("`v_F1'") ("`v_N'")
    post `1' (" ") ("`v_se'") (" ") (" ") (" ")	
	
***	Trade credit to total assets at the annual frequency
capture drop TRADECREDIT
gen TRADECREDIT=(c009/c015)*100
capture drop TRADECREDIT_w
winsor TRADECREDIT, gen(TRADECREDIT_w) p(0.02)
capture drop FC1
gen FC1=f.TRADECREDIT_w-l.TRADECREDIT_w
capture drop FC1_w2
winsor FC1, gen(FC1_w2) p(0.02)
ivreghdfe FC1_w2 `controls0' ///
	(l.last_it12_all = l.last_Treat) [aw=mean_peso], ///
	dkraay(2) absorb(i.setton5)		
	

outreg2 using "`out2'response_annual.dta", append  dec(3)  ///
	addstat( "1st stage F stat", e(widstat))  ctitle("Trade credit to total assets (CERVED)")	
	
	local t1=_b[l.last_it12_all]/_se[l.last_it12_all]
	if abs(`t1')<=1.645 local stars=""
	if abs(`t1')>1.645 local stars="*"
	if abs(`t1')>1.960 local stars="**"
	if abs(`t1')>2.326 local stars="***"
	
	local v_coef=string(_b[l.last_it12_all],"%4.3f")+"`stars'"
	local v_se  ="(" + string(_se[l.last_it12_all],"%4.3f")+")"
	local v_R2  =string(e(r2c),"%5.3f")
	local v_F1  = string(e(widstat),"%5.2f")
	local v_N  = string(e(N),"%8.0gc")
	
    post `1' ("Trade credit to total assets (CERVED)") ("`v_coef'") ("`v_R2'") ("`v_F1'") ("`v_N'")
    post `1' (" ") ("`v_se'") (" ") (" ") (" ")		

	
	
***	Liquidity (liquid assets to total assets) at the annual frequency
capture drop LIQUIDA
gen LIQUIDA=((c012+c011)/c015)*100
capture drop LIQUIDA_w
winsor LIQUIDA, gen(LIQUIDA_w) p(0.02)
capture drop FC1
gen FC1=f.LIQUIDA_w-l.LIQUIDA_w
capture drop FC1_w2
winsor FC1, gen(FC1_w2) p(0.02)
ivreghdfe FC1_w2 `controls0' ///
	(l.last_it12_all = l.last_Treat) [aw=mean_peso], ///
	dkraay(2) absorb(i.setton5)		
	

outreg2 using "`out2'response_annual.dta", append  dec(3)  ///
	addstat( "1st stage F stat", e(widstat))  ctitle("Liquidity A")	
	
	local t1=_b[l.last_it12_all]/_se[l.last_it12_all]
	if abs(`t1')<=1.645 local stars=""	
	if abs(`t1')>1.645 local stars="*"
	if abs(`t1')>1.960 local stars="**"
	if abs(`t1')>2.326 local stars="***"
	
	local v_coef=string(_b[l.last_it12_all],"%4.3f")+"`stars'"
	local v_se  ="(" + string(_se[l.last_it12_all],"%4.3f")+")"
	local v_R2  =string(e(r2c),"%5.3f")
	local v_F1  = string(e(widstat),"%5.2f")
	local v_N  = string(e(N),"%8.0gc")
	
	
    post `1' ("Cash & liquid financial funds to total assets (CERVED)") ("`v_coef'") ("`v_R2'") ("`v_F1'") ("`v_N'")
    post `1' (" ") ("`v_se'") (" ") (" ") (" ")	
	

		
***	Inventory to total assets at the annual frequency
capture drop Inventory
gen Inventory=c006/(c015)*100
capture drop Inventory_w
winsor Inventory, gen(Inventory_w) p(0.02)

capture drop FC1
gen FC1=f.Inventory_w-l.Inventory_w
capture drop FC1_w2
winsor FC1, gen(FC1_w2) p(0.02)
ivreghdfe FC1_w2 `controls0' ///
	(l.last_it12_all = l.last_Treat) [aw=mean_peso], ///
	dkraay(2) absorb(i.setton5)		
	

outreg2 using "`out2'response_annual.dta", append  dec(3)  ///
	addstat( "1st stage F stat", e(widstat))  ctitle("Inventory")	
			
	
	local t1=_b[l.last_it12_all]/_se[l.last_it12_all]
	if abs(`t1')<=1.645 local stars=""	
	if abs(`t1')>1.645 local stars="*"
	if abs(`t1')>1.960 local stars="**"
	if abs(`t1')>2.326 local stars="***"
	
	local v_coef=string(_b[l.last_it12_all],"%4.3f")+"`stars'"
	local v_se  ="(" + string(_se[l.last_it12_all],"%4.3f")+")"
	local v_R2  =string(e(r2c),"%5.3f")
	local v_F1  = string(e(widstat),"%5.2f")
	local v_N  = string(e(N),"%8.0gc")
	
	
    post `1' ("Inventory to total assets (CERVED)") ("`v_coef'") ("`v_R2'") ("`v_F1'") ("`v_N'")
    post `1' (" ") ("`v_se'") (" ") (" ") (" ")	
	
	
***	Leverage (ratio of financial debt to financial debt plus net equity) at the annual frequency
capture drop Leverage
gen Leverage = leverage
winsor Leverage, gen(Leverage_w) p(0.02)
capture drop FC1
gen FC1=f.Leverage_w-l.Leverage_w
capture drop FC1_w2
winsor FC1, gen(FC1_w2) p(0.02)
ivreghdfe FC1_w2 `controls0' ///
	(l.last_it12_all = l.last_Treat) [aw=mean_peso] , ///
	dkraay(2) absorb(i.setton5)		
	

outreg2 using "`out2'response_annual.dta", append  dec(3)  ///
	addstat( "1st stage F stat", e(widstat))  ctitle("Leverage")	

	local t1=_b[l.last_it12_all]/_se[l.last_it12_all]
	if abs(`t1')<=1.645 local stars=""
	if abs(`t1')>1.645 local stars="*"
	if abs(`t1')>1.960 local stars="**"
	if abs(`t1')>2.326 local stars="***"
	
	local v_coef=string(_b[l.last_it12_all],"%4.3f")+"`stars'"
	local v_se  ="(" + string(_se[l.last_it12_all],"%4.3f")+")"
	local v_R2  =string(e(r2c),"%5.3f")
	local v_F1  = string(e(widstat),"%5.2f")
	local v_N  = string(e(N),"%8.0gc")
	
	
    post `1' ("Leverage (CERVED)") ("`v_coef'") ("`v_R2'") ("`v_F1'") ("`v_N'")
    post `1' (" ") ("`v_se'") (" ") (" ") (" ")	
	
	
	
***	Average wages at the annual frequency
capture drop lnwage
gen lnwage=log(wagebill/nmed)
capture drop lnwage_w2
winsor lnwage, gen(lnwage_w2) p(0.02)
replace lnwage_w2=lnwage_w2*100

capture drop FC1
gen FC1=f.lnwage_w2-l.lnwage_w2
capture drop FC1_w2
winsor FC1, gen(FC1_w2) p(0.02)
ivreghdfe FC1_w2 `controls0' ///
	(l.last_it12_all = l.last_Treat) [aw=mean_peso], ///
	dkraay(2) absorb(i.setton5)		

outreg2 using "`out2'response_annual.dta", append  dec(3)  ///
	addstat( "1st stage F stat", e(widstat))  ctitle("Average wages")	
	
	local t1=_b[l.last_it12_all]/_se[l.last_it12_all]
	if abs(`t1')<=1.645 local stars=""	
	if abs(`t1')>1.645 local stars="*"
	if abs(`t1')>1.960 local stars="**"
	if abs(`t1')>2.326 local stars="***"
	
	local v_coef=string(_b[l.last_it12_all],"%4.3f")+"`stars'"
	local v_se  ="(" + string(_se[l.last_it12_all],"%4.3f")+")"
	local v_R2  =string(e(r2c),"%5.3f")
	local v_F1  = string(e(widstat),"%5.2f")
	local v_N  = string(e(N),"%8.0gc")
	
	
    post `1' ("Average wages (INPS)") ("`v_coef'") ("`v_R2'") ("`v_F1'") ("`v_N'")
    post `1' (" ") ("`v_se'") (" ") (" ") (" ")	
	
	
***	generate more aggregate measures of employment
gen impA_nmed=imp_nmed+dir_nmed			/* white collar + managers */
gen opeA_nmed=ope_nmed+app_nmed+nc_nmed /* blue collar + apprentices + other */

gen impA_wage=imp_wage+dir_wage
gen opeA_wage=ope_wage+app_wage+nc_wage


	
***	Average wages by group of people at the annual frequency
foreach var in "impA" "opeA" {
	noisily di "`var'"
	capture drop lnwage
	gen lnwage=log(`var'_wage/`var'_nmed)
	capture drop lnwage_w2
	winsor lnwage, gen(lnwage_w2) p(0.02)
	replace lnwage_w2=lnwage_w2*100

	capture drop FC1
	gen FC1=f.lnwage_w2-l.lnwage_w2
	capture drop FC1_w2
	winsor FC1, gen(FC1_w2) p(0.02)
	ivreghdfe FC1_w2 `controls0' ///
		(l.last_it12_all = l.last_Treat) [aw=mean_peso], ///
		dkraay(2) absorb(i.setton5)		
		
	outreg2 using "`out2'response_annual.dta", append  dec(3)  ///
		addstat( "1st stage F stat", e(widstat))  ctitle("Average wages: `var'")
		
	local t1=_b[l.last_it12_all]/_se[l.last_it12_all]
	if abs(`t1')<=1.645 local stars=""	
	if abs(`t1')>1.645 local stars="*"
	if abs(`t1')>1.960 local stars="**"
	if abs(`t1')>2.326 local stars="***"
	
	local v_coef=string(_b[l.last_it12_all],"%4.3f")+"`stars'"
	local v_se  ="(" + string(_se[l.last_it12_all],"%4.3f")+")"
	local v_R2  =string(e(r2c),"%5.3f")
	local v_F1  = string(e(widstat),"%5.2f")
	local v_N  = string(e(N),"%8.0gc")
	
	
    post `1' ("Wages: `var' (INPS)") ("`v_coef'") ("`v_R2'") ("`v_F1'") ("`v_N'")
    post `1' (" ") ("`v_se'") (" ") (" ") (" ")			
		
}

	


***	Share of group XXX of workers at the annual frequency
foreach var in  "impA" {
	noisily di "`var'"

	capture drop share_
	gen share_=`var'_nmed/nmed*100

	capture drop FC1
	gen FC1=f.share_-l.share_
	capture drop FC1_w2
	winsor FC1, gen(FC1_w2) p(0.02)
	ivreghdfe FC1_w2 `controls0' ///
		(l.last_it12_all = l.last_Treat) [aw=mean_peso], ///
		dkraay(2) absorb(i.setton5)	
		
		outreg2 using "`out2'response_annual.dta", append  dec(3)  ///
			addstat( "1st stage F stat", e(widstat))  ctitle("Employment share: `var'")	
			
	local t1=_b[l.last_it12_all]/_se[l.last_it12_all]
	if abs(`t1')<=1.645 local stars=""	
	if abs(`t1')>1.645 local stars="*"
	if abs(`t1')>1.960 local stars="**"
	if abs(`t1')>2.326 local stars="***"
	
	local v_coef=string(_b[l.last_it12_all],"%4.3f")+"`stars'"
	local v_se  ="(" + string(_se[l.last_it12_all],"%4.3f")+")"
	local v_R2  =string(e(r2c),"%5.3f")
	local v_F1  = string(e(widstat),"%5.2f")
	local v_N  = string(e(N),"%8.0gc")
	
	
    post `1' ("Employment share of white-collar workers (INPS)") ("`v_coef'") ("`v_R2'") ("`v_F1'") ("`v_N'")
    post `1' (" ") ("`v_se'") (" ") (" ") (" ")					
	
}


**** Employment share of temporary workers (INPS)
*** perc_td = share of temporary workers
    winsor perc_td, gen(perc_td_w) p(0.02)
	capture drop FC1
	gen FC1=f.perc_td_w -l.perc_td_w
	capture drop FC1_w2
	winsor FC1, gen(FC1_w2) p(0.02)
	ivreghdfe FC1_w2 `controls0' ///
		(l.last_it12_all = l.last_Treat) [aw=mean_peso], ///
		dkraay(2) absorb(i.setton5)	
		
		outreg2 using "`out2'response_annual.dta", append  dec(3)  ///
			addstat( "1st stage F stat", e(widstat))  ctitle("Employment share: `var'")	
			
	local t1=_b[l.last_it12_all]/_se[l.last_it12_all]
	if abs(`t1')<=1.645 local stars=""	
	if abs(`t1')>1.645 local stars="*"
	if abs(`t1')>1.960 local stars="**"
	if abs(`t1')>2.326 local stars="***"
	
	local v_coef=string(_b[l.last_it12_all],"%4.3f")+"`stars'"
	local v_se  ="(" + string(_se[l.last_it12_all],"%4.3f")+")"
	local v_R2  =string(e(r2c),"%5.3f")
	local v_F1  = string(e(widstat),"%5.2f")
	local v_N  = string(e(N),"%8.0gc")
	
	
    post `1' ("Employment share of temporary workers (INPS)") ("`v_coef'") ("`v_R2'") ("`v_F1'") ("`v_N'")
    post `1' (" ") ("`v_se'") (" ") (" ") (" ")					

	
  
postclose `1'  


***=============================================================================
*** wages for white-collar vs blue-collar workers
***=============================================================================

quiet foreach var in "impA" "opeA" {
	noisily di "`var'"
	capture drop lnwage`var'
	gen lnwage_`var'=log(`var'_wage/`var'_nmed)*100
	capture drop lnwage_`var'_w2
	winsor lnwage_`var', gen(lnwage_`var'_w2) p(0.02)
	replace lnwage_`var'_w2=lnwage_`var'_w2
}

gen lnwage_diff		=	lnwage_impA 	- lnwage_opeA
gen lnwage_diff_w2	=	lnwage_impA_w2 	- lnwage_opeA_w2

reg lnwage_diff	[aw=mean_peso], robust
reg lnwage_diff_w2	[aw=mean_peso], robust

areg lnwage_diff	[aw=mean_peso], robust absorb(setton5)
	
	
sum perc_td [aw=mean_peso]
sum perc_td_w [aw=mean_peso]
	
